<?php

namespace app\model;

use think\Model;

class Department extends Model
{
    public function children()
    {
        return $this->hasMany(Department::class, 'pid', 'id')
            ->where('is_delete', "=",0)
            ->field(["id", "pid","name", "code", "create_time"]);
    }

    public function allChildren()
    {
        return $this->children()->with('allChildren');
    }
}